﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components {
    import reprise.ui.*;
    import reprise.controls.*;

    public class TreatmentProgressDisplay extends SimpleButton {

        private var _timeTextDisplay:Label;
        private var _numTreatmentsTextDisplay:Label;
        private var _icon:UIComponent;
        private var _outline:UIComponent;
        private var _currentState:String;
        private var _isMouseOver:Boolean;

        private static const DEFAULT_EMPTY_FIELD_STRING:String = "00:00:00";
        private static const ICON_RUNNING_LABEL:String = "running";
        private static const ICON_ALARM_LABEL:String = "alarm";
        private static const RENDER_NUM_PENDING_TREATS_TRESHOLD:Number = 1;
        private static const ICON_OVER_SCALE:Number = 1.2;

        override protected function createChildren():void{
            this.addCSSClass("treatmentProgressDisplay");
            this._icon = this.addComponent("treatmentTimeIcon");
            this._numTreatmentsTextDisplay = (this.addComponent("showcardGothicFontOutline treatmentNumberDisplayTfield", null, Label) as Label);
            this._timeTextDisplay = (this.addComponent("showcardGothicFontOutline treatmentTimeProgressTfield", null, Label) as Label);
            this._isMouseOver = false;
            this.setHandCursor(true);
            this.hide();
        }
        private function setHandCursor(_arg1:Boolean):void{
            this.setStyle("cursor", (_arg1) ? "pointer" : "default");
        }
        public function startAlarmAnimation():void{
            if (this.isNotVisible()){
                this.show();
            };
            if (this._outline){
                this._outline.remove();
            };
            this.renderTimeToLabel(DEFAULT_EMPTY_FIELD_STRING);
            this.renderIcon(ICON_ALARM_LABEL);
            this.setState(ICON_ALARM_LABEL);
        }
        public function stopAlarmAnimation():void{
            this.renderTimeToLabel(DEFAULT_EMPTY_FIELD_STRING);
            this.renderIcon(ICON_RUNNING_LABEL);
            this.setState(ICON_RUNNING_LABEL);
        }
        public function updateNumTreatments(_arg1:int):void{
            if (_arg1 > RENDER_NUM_PENDING_TREATS_TRESHOLD){
                this._numTreatmentsTextDisplay.show();
            } else {
                this._numTreatmentsTextDisplay.hide();
            };
            this._numTreatmentsTextDisplay.label = String(_arg1);
        }
        public function deselect():void{
            this._outline.remove();
            this._outline = null;
            this._icon.scaleX = (this._icon.scaleY = 1);
            this._timeTextDisplay.removeCSSClass("over");
            this._isMouseOver = false;
        }
        public function select():void{
            this._outline = this.addComponent("outline");
            this._outline.scaleX = (this._outline.scaleY = (this._icon.scaleX = (this._icon.scaleY = ICON_OVER_SCALE)));
            this._timeTextDisplay.addCSSClass("over");
            this._isMouseOver = true;
        }
        public function get isSelected():Boolean{
            return (this._isMouseOver);
        }
        private function isNotVisible():Boolean{
            return ((this.visibility() == false));
        }
        private function renderIcon(_arg1:String):void{
            if (_arg1 == ICON_RUNNING_LABEL){
                this._icon.removeCSSClass(ICON_ALARM_LABEL);
                this._icon.addCSSClass(ICON_RUNNING_LABEL);
            } else {
                if (_arg1 == ICON_ALARM_LABEL){
                    this._icon.addCSSClass(ICON_ALARM_LABEL);
                    this._icon.removeCSSClass(ICON_RUNNING_LABEL);
                } else {
                    throw (new Error((("Trying to set the icon clip to an illegal frame label / css class property [ " + _arg1) + "]")));
                };
            };
        }
        private function get timeTextLabel():Label{
            return (this._timeTextDisplay);
        }
        private function setState(_arg1:String):void{
            this._currentState = _arg1;
        }
        public function renderTimeToLabel(_arg1:String):void{
            this.timeTextLabel.setLabel(_arg1);
        }

    }
}//package net.wooga.pets.views.components 
